<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
    return redirect('/admin/index');
    //    return view('home');
});
//Api调用接口
//Route::get('api', ['uses' => 'Api\\ApiController@index']);
//Route::get('api/upgradeTemplate', ['as' => 'Api.upgradeTemplate', 'uses' => 'Api\\ApiController@upgradeTemplate']);
//Route::get('api/upgradeCompanyTemplate', ['as' => 'Api.upgradeCompanyTemplate', 'uses' => 'Api\\ApiController@upgradeCompanyTemplate']);

$router->group(['namespace' => 'Api', 'middleware' => 'EnableCrossRequest'],function () {
    Route::get('api', ['uses' => 'ApiController@index']);
    Route::get('api/upgradeTemplate', ['as' => 'Api.upgradeTemplate', 'uses' => 'ApiController@upgradeTemplate']);
    Route::get('api/upgradeCompanyTemplate', ['as' => 'Api.upgradeCompanyTemplate', 'uses' => 'ApiController@upgradeCompanyTemplate']);
	Route::post('api/query', ['as' => 'Api.query', 'uses' => 'ApiController@query']);
	Route::get('api/query/{uid}', ['as' => 'Api.query', 'uses' => 'ApiController@query']);
	Route::get('api/updateTemplate', ['as' => 'Api.updateTemplate', 'uses' => 'ApiController@updateTemplate']);
    //更新模板路由
	Route::post('api/originate', ['uses' => 'ApiController@originate']); //新增来源
    Route::post('api/copywechat', ['uses' => 'ApiController@copywechat']); //新增CP监控
    Route::post('api/sms', ['uses' => 'ApiController@smsUpdateStatus']); //更新状态
    
});

Route::get('/home', function () {
    return view('welcome');
});
Route::get('admin/templates/{id}/preview', ['uses' => 'Admin\\TemplatesController@preview']); //模板预览
//Route::get('admin/build/getTemplateHtml/{id?}', ['as' => 'admin.build', 'uses' => 'BuildController@getTemplateHtml']);

Route::get('admin/index', ['as' => 'admin.index', 'middleware' => ['auth', 'menu'], 'uses' => 'Admin\\IndexController@index']);

$this->group(['namespace' => 'Admin', 'prefix' => '/admin',], function () {
    Route::auth();
});

//后台菜单管理
$router->group(['namespace' => 'Admin', 'middleware' => ['auth', 'authAdmin', 'menu']], function () {
    //权限管理路由
    Route::get('admin/permission/{cid}/create', ['as' => 'admin.permission.create', 'uses' => 'PermissionController@create']);
    Route::get('admin/permission/{cid?}', ['as' => 'admin.permission.index', 'uses' => 'PermissionController@index']);
    Route::post('admin/permission/index', ['as' => 'admin.permission.index', 'uses' => 'PermissionController@index']); //查询

    Route::resource('admin/permission', 'PermissionController');
    Route::put('admin/permission/update', ['as' => 'admin.permission.edit', 'uses' => 'PermissionController@update']); //修改
    Route::post('admin/permission/store', ['as' => 'admin.permission.create', 'uses' => 'PermissionController@store']); //添加

    //角色管理路由
    Route::get('admin/role/index', ['as' => 'admin.role.index', 'uses' => 'RoleController@index']);
    Route::post('admin/role/index', ['as' => 'admin.role.index', 'uses' => 'RoleController@index']);//查询
    Route::resource('admin/role', 'RoleController');
    Route::put('admin/role/update', ['as' => 'admin.role.edit', 'uses' => 'RoleController@update']); //修改
    Route::post('admin/role/store', ['as' => 'admin.role.create', 'uses' => 'RoleController@store']); //添加
	
	Route::get('admin/history/index', ['as' => 'admin.history.index', 'uses' => 'HistoryController@index']);  //操作记录
    Route::post('admin/history/index', ['as' => 'admin.history.index', 'uses' => 'HistoryController@index']);
	Route::resource('admin/history', 'HistoryController');

    //用户管理路由
    Route::get('admin/user/manage', ['as' => 'admin.user.manage', 'uses' => 'UserController@index']);  //用户管理
    Route::post('admin/user/index', ['as' => 'admin.user.index', 'uses' => 'UserController@index']);//查询
    Route::resource('admin/user', 'UserController');
    Route::put('admin/user/update', ['as' => 'admin.user.edit', 'uses' => 'UserController@update']); //修改
    Route::post('admin/user/store', ['as' => 'admin.user.create', 'uses' => 'UserController@store']); //添加

    //广告分组路由
    Route::get('admin/group/manage', ['as' => 'admin.group.manage', 'uses' => 'GroupController@index']);
    Route::post('admin/group/index', ['as' => 'admin.group.index', 'uses' => 'GroupController@index']);//查询
    Route::resource('admin/group', 'GroupController');
    Route::put('admin/group/update', ['as' => 'admin.group.edit', 'uses' => 'GroupController@update']); //修改
    Route::post('admin/group/store', ['as' => 'admin.group.create', 'uses' => 'GroupController@store']); //添加


    //分组附加属性路由
    Route::post('admin/groupAttr/index', ['as' => 'admin.groupAttr.index', 'uses' => 'GroupAttrController@index']);//查询
    Route::resource('admin/groupAttr', 'GroupAttrController');
    Route::put('admin/groupAttr/update', ['as' => 'admin.groupAttr.edit', 'uses' => 'GroupAttrController@update']); //修改
    Route::post('admin/groupAttr/store', ['as' => 'admin.groupAttr.create', 'uses' => 'GroupAttrController@store']); //添加

    //域名管理路由
    Route::post('admin/domain/index', ['as' => 'admin.domain.index', 'uses' => 'DomainController@index']);//查询
    Route::resource('admin/domain', 'DomainController');
    Route::put('admin/domain/update', ['as' => 'admin.domain.edit', 'uses' => 'DomainController@update']); //修改
	Route::post('admin/domain/setStatus', ['as' => 'admin.domain.edit', 'uses' => 'DomainController@setStatus']); //域名启用和禁用
    Route::post('admin/domain/store', ['as' => 'admin.domain.create', 'uses' => 'DomainController@store']); //添加
    Route::get('admin/domain/{id}/{token}/{tpl_id}/upgradeTpl', ['as' => 'admin.domain.upgradeTpl', 'uses' => 'DomainController@upgradeTpl']);
    Route::get('admin/domain/{id}/resetToken', ['as' => 'admin.domain.resetToken', 'uses' => 'DomainController@resetToken']);
	Route::post('admin/domain/crossUpTpl', ['as' => 'admin.domain.edit', 'uses' => 'DomainController@crossUpTpl']); //更新模板
	Route::post('admin/domain/crossGUpTpl', ['as' => 'admin.domain.edit', 'uses' => 'DomainController@crossGUpTpl']); //更新分组模板
	Route::post('admin/domain/per', ['as' => 'admin.domain.edit', 'uses' => 'DomainController@per']); //获取需要更新的数量
	
	
    //域名附加属性路由
    Route::post('admin/domainAttr/index', ['as' => 'admin.domainAttr.index', 'uses' => 'DomainAttrController@index']);//查询
    Route::resource('admin/domainAttr', 'DomainAttrController');
    Route::put('admin/domainAttr/update', ['as' => 'admin.domainAttr.edit', 'uses' => 'DomainAttrController@update']); //修改
    Route::post('admin/domainAttr/store', ['as' => 'admin.domainAttr.create', 'uses' => 'DomainAttrController@store']); //添加

    //模板
    Route::get('admin/templates/manage', ['as' => 'admin.templates.manage', 'uses' => 'TemplatesController@index']); //查询
    Route::post('admin/templates/index', ['as' => 'admin.templates.index', 'uses' => 'TemplatesController@index']);
    Route::resource('admin/templates', 'TemplatesController');
    Route::put('admin/templates/update', ['as' => 'admin.templates.edit', 'uses' => 'TemplatesController@update']); //修改
    Route::post('admin/templates/store', ['as' => 'admin.templates.create', 'uses' => 'TemplatesController@store']); //添加
	Route::get('admin/templates/leading/{id?}', ['as' => 'admin.templates.leading', 'uses' => 'TemplatesController@leading']); //导入模板
	Route::post('admin/templates/import', ['as' => 'admin.templates.edit', 'uses' => 'TemplatesController@import']); //批量保存
	
	
	//微信号管理
	Route::get('admin/wechat/create', ['as' => 'admin.wechat.create', 'uses' => 'WechatController@create']); //添加
    Route::get('admin/wechat/manage', ['as' => 'admin.wechat.manage', 'uses' => 'WechatController@index']); //查询
    Route::post('admin/wechat/index', ['as' => 'admin.wechat.index', 'uses' => 'WechatController@index']);
	Route::get('admin/wechat/{gid?}', ['as' => 'admin.wechat.index', 'uses' => 'WechatController@index']);
    Route::resource('admin/wechat', 'WechatController');
    Route::put('admin/wechat/update', ['as' => 'admin.wechat.edit', 'uses' => 'WechatController@update']); //修改
    Route::post('admin/wechat/store', ['as' => 'admin.wechat.create', 'uses' => 'WechatController@store']); //添加
	Route::get('admin/wechat/leading/{id?}', ['as' => 'admin.wechat.leading', 'uses' => 'WechatController@leading']); //导入域名
	Route::post('admin/wechat/import', ['as' => 'admin.wechat.import', 'uses' => 'WechatController@import']); //批量保存
	Route::post('admin/wechat/cogsUpdate', ['as' => 'admin.wechat.cogsUpdate', 'uses' => 'WechatController@cogsUpdate']); //批量修改
	Route::post('admin/wechat/recover', ['as' => 'admin.wechat.edit', 'uses' => 'WechatController@recover']); //申请回收
	//Route::post('admin/wechat/{id}', ['as' => 'admin.wechat.edit', 'uses' => 'WechatController@stop']); //取消申请
	//Route::get('admin/counts/{gid?}/index', ['as' => 'admin.counts.index', 'uses' => 'WechatController@index']);
	
	//微信号分组
	Route::get('admin/wechatgroup/index', ['as' => 'admin.wechatgroup.index', 'uses' => 'WechatGroupController@index']); //查询
    Route::post('admin/wechatgroup/index', ['as' => 'admin.wechatgroup.index', 'uses' => 'WechatGroupController@index']);
    Route::resource('admin/wechatgroup', 'WechatGroupController');
    Route::put('admin/wechatgroup/update', ['as' => 'admin.wechatgroup.edit', 'uses' => 'WechatGroupController@update']); //修改
    Route::post('admin/wechatgroup/store', ['as' => 'admin.wechatgroup.create', 'uses' => 'WechatGroupController@store']); //添加
	
	//微信号调用值
	Route::get('admin/wechatvalue/{wid}/index', ['as' => 'admin.wechatvalue.index', 'uses' => 'WechatValueController@index']); //查询
	Route::get('admin/wechatvalue/{wid?}', ['as' => 'admin.wechatvalue.index', 'uses' => 'WechatValueController@index']);
    Route::post('admin/wechatvalue/{wid}/index', ['as' => 'admin.wechatvalue.index', 'uses' => 'WechatValueController@index']);
    Route::resource('admin/wechatvalue', 'WechatValueController');
    Route::put('admin/wechatvalue/update', ['as' => 'admin.wechatvalue.edit', 'uses' => 'WechatValueController@update']); //修改
    Route::get('admin/wechatvalue/{wid}/create', ['as' => 'admin.wechatvalue.create', 'uses' => 'WechatValueController@create']); //创建
    Route::post('admin/wechatvalue/store', ['as' => 'admin.wechatvalue.create', 'uses' => 'WechatValueController@store']); //添加
	Route::post('admin/wechatvalue/{id}/update', ['as' => 'admin.wechatvalue.update', 'uses' => 'WechatValueController@update']); //修改
	Route::get('admin/wechatgroupuser/{gid}/show', ['as' => 'admin.wechatgroupuser.index', 'uses' => 'WechatGroupUserController@show']);//显示已授权的名单
	Route::get('admin/wechatvalue/leading/{wid?}', ['as' => 'admin.wechatvalue.create', 'uses' => 'WechatValueController@leading']); //导入调用值
	Route::post('admin/wechatvalue/import', ['as' => 'admin.wechatvalue.create', 'uses' => 'WechatValueController@import']); //导入调用值
	Route::post('admin/wechatvalue/cogsUpdate', ['as' => 'admin.wechatvalue.edit', 'uses' => 'WechatValueController@cogsUpdate']); //批量修改
	
	//微信号分组授权
	Route::get('admin/wechatgroupuser/{gid}/index', ['as' => 'admin.wechatgroupuser.index', 'uses' => 'WechatGroupUserController@index']); //查询
	Route::get('admin/wechatgroupuser/{gid?}', ['as' => 'admin.wechatgroupuser.index', 'uses' => 'WechatGroupUserController@index']);
    Route::post('admin/wechatgroupuser/{gid}/index', ['as' => 'admin.wechatgroupuser.index', 'uses' => 'WechatGroupUserController@index']);
    Route::resource('admin/wechatgroupuser', 'WechatGroupUserController');
    Route::put('admin/wechatgroupuser/update', ['as' => 'admin.wechatgroupuser.edit', 'uses' => 'WechatGroupUserController@update']); //修改
    Route::get('admin/wechatgroupuser/{gid}/create', ['as' => 'admin.wechatgroupuser.create', 'uses' => 'WechatGroupUserController@create']); //创建
    Route::post('admin/wechatgroupuser/store', ['as' => 'admin.wechatgroupuser.create', 'uses' => 'WechatGroupUserController@store']); //添加
	Route::post('admin/wechatgroupuser/{id}/update', ['as' => 'admin.wechatgroupuser.update', 'uses' => 'WechatGroupUserController@update']); //修改
	
	//用户反馈管理
    Route::post('admin/query/index', ['as' => 'admin.query.index', 'uses' => 'QueryController@index']);
	Route::get('admin/query', ['as' => 'admin.query.index', 'uses' => 'QueryController@index']);
    Route::resource('admin/query', 'QueryController');
    Route::put('admin/query/update', ['as' => 'admin.query.edit', 'uses' => 'QueryController@update']); //修改
	
		
	//域名检测
    Route::get('admin/domainame/index', ['as' => 'admin.domainame.index', 'uses' => 'DomainameController@index']); //查询
    Route::get('admin/domainame/checkall', ['as' => 'admin.domainame.checkall', 'uses' => 'DomainameController@checkall']); //检测所有域名
    Route::post('admin/domainame/index', ['as' => 'admin.domainame.index', 'uses' => 'DomainameController@index']);
    Route::resource('admin/domainame', 'DomainameController');
    Route::put('admin/domainame/update', ['as' => 'admin.domainame.edit', 'uses' => 'DomainameController@update']); //修改
    Route::post('admin/domainame/store', ['as' => 'admin.domainame.create', 'uses' => 'DomainameController@store']); //添加
	
	//回收申请
	Route::get('admin/wechatrecover/index', ['as' => 'admin.wechatrecover.index', 'uses' => 'WechatRecoverController@index']); //查询
	Route::post('admin/wechatrecover/index', ['as' => 'admin.wechatrecover.index', 'uses' => 'WechatRecoverController@index']); //查询
	Route::post('admin/wechatrecover/{id}', ['as' => 'admin.wechatrecover.update', 'uses' => 'WechatRecoverController@recover']); //修改
	
	Route::get('admin/wechatgroupuser/{gid}/show', ['as' => 'admin.wechatgroupuser.index', 'uses' => 'WechatGroupUserController@show']);//显示已授权的名单

	//条件
    Route::post('admin/term/index', ['as' => 'admin.term.index', 'uses' => 'TermController@index']);
    Route::resource('admin/term', 'TermController');
    Route::put('admin/term/update', ['as' => 'admin.term.edit', 'uses' => 'TermController@update']); //修改
    Route::post('admin/term/store', ['as' => 'admin.term.create', 'uses' => 'TermController@store']); //添加
	
	//报表统计
	Route::get('admin/originate/manage', ['as' => 'admin.report.manage', 'uses' => 'OriginateController@index']);  //
	//来源统计
    Route::get('admin/originate/index', ['as' => 'admin.originate.index', 'uses' => 'OriginateController@index']);  //
    Route::post('admin/originate/index', ['as' => 'admin.originate.index', 'uses' => 'OriginateController@index']);//查询
	Route::post('admin/originate/table', ['as' => 'admin.originate.table', 'uses' => 'OriginateController@table']);//表格界面
	Route::get('admin/originate/table', ['as' => 'admin.originate.table', 'uses' => 'OriginateController@table']); 
    Route::resource('admin/originate', 'OriginateController');

	
	//短信模板
    Route::get('admin/smstemplate/index', ['as' => 'admin.smstemplate.index', 'uses' => 'SmsTemplateController@index']);  //
    Route::post('admin/smstemplate/index', ['as' => 'admin.smstemplate.index', 'uses' => 'SmsTemplateController@index']);//查询
	Route::resource('admin/smstemplate', 'SmsTemplateController');
	Route::put('admin/smstemplate/update', ['as' => 'admin.smstemplate.edit', 'uses' => 'SmsTemplateController@update']); //修改
    Route::post('admin/smstemplate/store', ['as' => 'admin.smstemplate.create', 'uses' => 'SmsTemplateController@store']); //添加
	
	//留言统计
	Route::post('admin/chart/index', ['as' => 'admin.chart.index', 'uses' => 'QueryController@chart']);//图形界面
	Route::get('admin/chart', ['as' => 'admin.chart.index', 'uses' => 'QueryController@chart']);
	//Route::resource('admin/chart', 'QueryController');
	Route::post('admin/chart/table', ['as' => 'admin.chart.table', 'uses' => 'QueryController@table']);//表格界面
	Route::get('admin/table', ['as' => 'admin.chart.table', 'uses' => 'QueryController@table']);

    // sygr 推广系统
    Route::get('admin/spread/manage', ['as' => 'admin.spread.manage', 'uses' => 'SpreadController@index']);  
    Route::get('admin/spread/index', ['as' => 'admin.spread.index', 'uses' => 'SpreadController@index']);

    //复制数据CopyAccount
    Route::get('admin/copy/manage', ['as' => 'admin.copy.manage', 'uses' => 'CopyController@index']);  //复制数据
    Route::post('admin/copy/index', ['as' => 'admin.copy.index', 'uses' => 'CopyController@index']);//查询
    Route::resource('admin/copy', 'CopyController');
    Route::put('admin/copy/update', ['as' => 'admin.copy.edit', 'uses' => 'CopyController@update']); //更新数据
    Route::post('admin/copy/store', ['as' => 'admin.copy.create', 'uses' => 'CopyController@store']); //添加
    Route::put('admin/copy/batch', ['as' => 'admin.copy.edit', 'uses' => 'CopyController@batch']); //批处理

});

Route::get('admin', function () {
    return redirect('/admin/index');
});

Route::auth();